package server

import (
	"log"
	"mlss-cc-a/internal/middleware"
	"mlss-cc-a/internal/routes"
	"net/http"
)

func HTTPServe(add string) {
	router := http.NewServeMux()

	routes.SetupTestRoutes(router)

	stack := middleware.CreateStack(
		middleware.Logging,
	)
	server := http.Server{
		Addr:    add,
		Handler: stack(router),
	}

	log.Println("Starting server on ", add)
	if err := server.ListenAndServe(); err != nil {
		log.Panic("Error starting server: ", err.Error())
	}
}
